﻿
@{
    ViewBag.Title = "云医继教管理系统数据筛查工具";
    Layout = "~/Views/Shared/Pgae_Layout.cshtml";

}

<div class="blank" style="padding-top:8%">
</div>
<div class="logo_text">
    <h1>云医继教管理系统数据筛查工具</h1>
</div>
@using (Html.BeginForm("Index", "Search", FormMethod.Post, new { @id = "Form", @role = "form", enctype = "multipart/form-data" }))
{
    <div class="choose_db">
        <div class="dropdown">
            <input type="hidden" class="dropdown-selected-value" name="" value="-1" />
            <a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <span class="dropdown-selected-text">选择数据源</span> <span class="caret"></span>
            </a>
            <ul class="dropdown-menu clearfix pull-right" style="right:42%">
                <li data-value="0" data-type="DataDource" data-title="宜宾数据源"><a href="#">宜宾数据源</a></li>
                <li data-value="1" data-type="DataDource" data-title="甘孜数据源"><a href="#">甘孜数据源 </a></li>
                <li data-value="2" data-type="DataDource" data-title="测试数据源"><a href="#">测试数据源 </a></li>
            </ul>
        </div>
    </div>
    <div class="main_file">
        <div class="col-md-2">
            <div class="dropdown pull-right">
                <input type="hidden" class="dropdown-selected-value" name="" value="-1" />
                <a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                    <span class="dropdown-selected-text">选择导入类别</span> <span class="caret"></span>
                </a>
                <ul class="dropdown-menu ">
                    <li data-value="0" data-type="DataType" data-title="机构数据"><a href="#">机构数据</a></li>
                    <li data-value="1" data-type="DataType" data-title="人员数据"><a href="#">人员数据</a></li>
                    <li data-value="2" data-type="DataType" data-title="学分数据"><a href="#">学分数据</a></li>
                </ul>
            </div>
        </div>
        <div class="col-md-10">
            <input id="ChooseFile" name="input-b2" type="file" class="file">
        </div>
    </div>
    <div class="submitBtn">
        <button type="submit" class="btn btn-warning col_padding">开始筛查</button>
    </div>
}

<input type="hidden" name="FilterFilePath" value="@ViewBag.FilterFilePath" />

<div class="panel panel-default" id="ShowFile">
    <div class="panel-body">
        文件下载地址：<a href="@ViewBag.FilterFilePath">点击下载</a>
    </div>
</div>

<div class="div_postion">
    <div class="alert alert-info alert-dismissible fade in" role="alert" id="myAlert">
    </div>
</div>



<script>

    $(function () {
        var dropdown = $(".dropdown");
        dropdown.find("li").click(function () {
            var item = $(this);
            var value = item.attr("data-value");
            var text = item.attr("data-title");
            var dataType = item.attr("data-type");
            item.parent().parent().find(".dropdown-selected-value").val(value);
            item.parent().parent().find(".dropdown-selected-value").attr("name", dataType);
            item.parent().parent().find(".dropdown-selected-text").text(text);
        });
        initFileInput("ChooseFile", "/Upload/");

        var filepath = $("input[name='FilterFilePath']").val();
        if (filepath != "") {
            $("#ShowFile").show();
        } else {
            $("#ShowFile").hide();
        }
    });
    //初始化fileinput控件（第一次初始化）
    function initFileInput(ctrlName, uploadUrl) {
        var control = $('#' + ctrlName);
        control.fileinput({
            language: 'zh', //设置语言
            uploadUrl: uploadUrl, //上传的地址
            allowedFileExtensions: ['xls', 'xlsx'],//接收的文件后缀
            showUpload: false, //是否显示上传按钮
            showCaption: false,//是否显示标题
            browseClass: "btn btn-primary", //按钮样式
            previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
        });
    }
    function AlertMessage(flage, ErrorMessage) {
        var temp = "<button type='button' class='close' data-dismiss='alert' aria-label='close'><span aria-disabled='true'>×</span></button>";
        if (flage) {
            temp += ErrorMessage;
            $(".div_postion>#myAlert").html(temp);
            $(".div_postion").show();
        }
        else {
            $(".div_postion").hide();
        }

    }
</script>

@switch (Request["message"])
{
    case "500":
        <script>
            AlertMessage(true, "文件类型只能是*.xls或者是*.xlsx");
        </script>
        break;
    case "200":
        <script>
            AlertMessage(true, "没有选择数据源！！！");
        </script>
        break;
    case "300":
        <script>
            AlertMessage(true, "没有选择导入类别！！！");
        </script>
        break;
    case "0":
        <script>
            AlertMessage(true, "位未知错误，ERROR：500");
        </script>
        break;
    case "100":
        <script>
            AlertMessage(true, "对不起，导入的文件没有一行数据！！，请重新上传");
        </script>
        break;
}
